﻿import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MemoryInfo {
    public MemoryInfo() {
    }

    public static void main(String[] args) {
        try {
            String output, err;
            String[] cmd = { "systeminfo.exe" };
            Process proc = Runtime.getRuntime().exec(cmd);

            BufferedReader stdout = new BufferedReader(new InputStreamReader(
                    proc.getInputStream()));
            BufferedReader stderr = new BufferedReader(new InputStreamReader(
                    proc.getErrorStream()));

            try {
                while ((output = stdout.readLine()) != null) {
                    if (output.indexOf("메모리") > 0) {
                        System.out.println(output);
                    }
                }
                while ((err = stderr.readLine()) != null) {
                    System.out.println(err);
                }
            } catch (IOException e) {
                System.exit(0);
            }
        } catch (IOException e1) {
            System.err.println(e1);
            System.exit(1);
        }
    }
}
